package com.briup.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.briup.bean.Slideshow;
import com.briup.mapper.SlideshowMapper;
import com.briup.service.ISlideshowService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author syh
 * @since 2024-09-10
 */
@Service
public class SlideshowServiceImpl extends ServiceImpl<SlideshowMapper, Slideshow> implements ISlideshowService {
    @Autowired
    private SlideshowMapper mapper;

    @Override
    public IPage<Slideshow> findByPage(int pageNum, int pageSize, String desc, String status) {
        IPage<Slideshow> pageParam =new Page<>(pageNum,pageSize,true);
        IPage<Slideshow> pageInfo = mapper.selectPage(pageParam, null);
        return pageInfo;
    }

    @Override
    public List<Slideshow> findAll() {
       return mapper.selectList(null);
    }

    @Override
    public Slideshow findById(String id) {
        Slideshow slideshow = mapper.selectById(id);
        return slideshow;
    }

    @Override
    public void deleteByBatch(String ids) {
        mapper.deleteById(ids);
    }


    @Override
    public boolean save(Slideshow entity) {
        if(entity.getId()==null){
            mapper.insert(entity);
        }else{
            mapper.updateById(entity);
        }
        return super.save(entity);
    }
}
